/**
 * @Author ZhangCuirong
 * @Date 2025/8/14 9:30
 * @description:
 */
public class Solution69 {
    public int mySqrt(int x) {
        if(x ==0){
            return 0;
        }
        int left = 1, right = x;
        while (left <= right) {
            int mid = (left + right) / 2;
            if (mid == x / mid) {
                return mid;
            } else if (mid < x / mid) {
                left = mid + 1;
            } else {
                right = mid - 1;
            }
        }
        return right;
    }

    public static void main(String[] args) {
        Solution69 solution = new Solution69();
        int res = solution.mySqrt(0);
        System.out.println(res);
    }
}
